#include <bits/stdc++.h>
#define ll long long
using namespace std;

const int Maxn=1010,N=1e3;
const int Mod=1e9+7;
int n,m;
int a[Maxn][Maxn];
ll f[Maxn];

int main(){
    freopen("disanti.in","r",stdin);
    freopen("disanti.out","w",stdout);
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            scanf("%1d",&a[i][j]);
    f[0]=1;
    for(int i=1;i<=N;i++)
        for(int j=1;j<=i;j++)
            f[i]=(f[i]+f[i-j])%Mod;
    for(int i=1;i<=n;i++,puts(""))
        for(int j=1;j<=m;j++){
            a[i][j]^=1;
            int c=1;
            ll ans=1;
            for(int k=2;k<=m;k++){
                c=1;
                while(a[1][k]==a[1][k-1] and k<=m) k++,c++;
                ans=ans*f[c]%Mod;
            }
            a[i][j]^=1;
            printf("%lld ",ans);
        }

    return 0;
}
